package com.ukao.steward.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.ukao.steward.R;
import com.ukao.steward.base.ListBaseAdapter;
import com.ukao.steward.base.SuperViewHolder;
import com.ukao.steward.bean.ShoppingBean;
import com.ukao.steward.util.CheckUtils;
import com.ukao.steward.util.DensityUtils;
import com.ukao.steward.util.ImageUtils;

import java.util.List;

/**
 * Created by ukaodev on 2017/8/24.
 */

public class ShoppListAdapter extends ListBaseAdapter<ShoppingBean> {



    public ShoppListAdapter(Context context, List<ShoppingBean> mHomeBean) {
        super(context, mHomeBean);
    }

    @Override
    public int getLayoutId() {
        return R.layout.adapter_shape_list;
    }

    @Override
    public void onBindItemHolder(SuperViewHolder holder, int position) {
        LinearLayout homeItemLayout = holder.getView(R.id.shop_item_layout);
        ViewGroup.LayoutParams mParams = homeItemLayout.getLayoutParams();
        int heigh = (DensityUtils.getScreenW() - DensityUtils.dip2px(10)) / 3;
        mParams.height = (int) ((heigh / 0.44) * 0.56);
        homeItemLayout.setLayoutParams(mParams);
        TextView name=holder.getView(R.id.product_name);
        TextView pice=holder.getView(R.id.pice);
        ImageView imageView=holder.getView(R.id.image_view);
        TextView count=holder.getView(R.id.count);
        ShoppingBean item = mDataList.get(position);
        name.setText(item.getName());
        pice.setText(CheckUtils.isEmptyNumber(item.getPrice()));
        ImageUtils.loadImage(mContext,item.getImgPath(),imageView);
        if (item.getCount()==0){
            count.setVisibility(View.GONE);
        }else{
            count.setText(item.getCount()+"");
            count.setVisibility(View.VISIBLE);
        }







    }

}
